import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/material.dart';

class WyConstrained extends StatefulWidget {
  const WyConstrained({Key? key}) : super(key: key);

  @override
  _WyConstrainedState createState() => _WyConstrainedState();
}

class _WyConstrainedState extends State<WyConstrained> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar('约束限制容器'),
      body: _buildSizeBox1(),

    );
  }
  _buildConstrainedBox(){
    return ConstrainedBox(
      constraints: BoxConstraints(maxHeight: 60, maxWidth: 200),
      child: Container(height: 300, width: 300, color: Colors.yellow),
    );
  }
  _buildConstrainedBox1(){
    return ConstrainedBox(
      constraints: BoxConstraints(maxHeight: 60, maxWidth: 200),
      child: ConstrainedBox(
        constraints: BoxConstraints(maxHeight: 100, maxWidth: 240),
        child: Container(height: 300, width: 300, color: Colors.red),
      ),
    );
  }
  _buildUnconstrainedBox(){
    return Container(
      height: 200,
      width: 200,
      child: UnconstrainedBox(
        alignment: Alignment.topLeft,
        child: Container(height: 300, width: 300, color: Colors.blue),
      ),
    );
  }
  _buildSizeBox(){
    return SizedBox(
      height: 200,
      width: double.infinity,
      child: ElevatedButton(
        onPressed: () {  },
        child: Text('this is SizedBox'),
      ),
    );
  }
  _buildSizeBox1(){
    return Row(
      children: <Widget>[
        Expanded(
          flex: 1,
            child: Container(color: Colors.green,)),

        Expanded(
            flex: 3,
            child: Container(color: Colors.yellow,))
      ],
    );
  }
}
